module ActiveRecord::Validations::ClassMethods
  def validates_not_zero(*attr_names)
    configuration = { :message => "can't be zero", :on => :save, :allow_nil => true }
    configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)

    validates_each(attr_names, configuration) do |record, attr_name, value|
      record.errors.add(attr_name, configuration[:message]) unless (configuration[:allow_nil] && (value.nil? || value.blank?)) || value != 0
    end
  end
end